

class Proactor(object):

    def __init__(self):
        pass


    def dispatch(self, type_, handler, value):
        handler.handle_event(type_, value)





class EventHandler(object):

    def handle_event(self, type_, value):
        if type_ == "accept":
            self.handle_accept(value[0], value[1])
        elif type_ == "connect":
            self.handle_connect()
        elif type_ == "recv":
            self.handle_recv(value)
        elif type_ == "send":
            self.handle_send(value)
        else:
            raise ValueError, "unknown event type"


    def handle_accept(self, client_socket, remote_address):
        raise NotImplementedException, "unsupported operation"


    def handle_connect(self):
        raise NotImplementedException, "unsupported operation"


    def handle_recv(self, buf):
        raise NotImplementedException, "unsupported operation"


    def handle_send(self, cnt):
        raise NotImplementedException, "unsupported operation"
